<extend name="Base/common"/>
<block name="body">
    <script type="text/javascript">
    //调用微信JS api 支付
    function jsApiCall()
    {
        //alert("{$returnurl}");
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
             {$jsApiParameters},
            function(res){
                //WeixinJSBridge.log(res.err_msg);
                //alert(res.err_code+res.err_desc+res.err_msg);
                if(res.err_msg=='get_brand_wcpay_request:ok'){
                    //alert('恭喜您，支付成功!');
                    window.location.href="{$sucurl}";
                }else{
                    window.location.href="{$errurl}";
                    //alert('支付失败');
                    //alert('支付失败'+res.err_msg);//这里一直返回getBrandWCPayRequest提示fail_invalid appid
                }
            }
        );
    }

    function callpay()
    {
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        }else{
            jsApiCall();
        }
    }
    </script>
    <!--
	<div class="container">
		<h4 class="insure">确认充值</h4>
        <input type="hidden"></input>	
		<input type="submit" onclick="callpay()" class="incharge" value="付 款">
	</div>
    -->
    <div class="container">
        <p class="insure">应支付金额为：<strong> {$money} </strong>元</p>
        <div class="insure_bar">
            <input type="button" class="insure_btn insure_sure" onclick="callpay()" value="确认支付">           
        </div>  
        
    </div>
</block>

